package com.lh.api.controller;

import com.lh.api.annotation.Login;
import com.lh.api.annotation.LoginUser;
import com.lh.api.entity.UserEntity;
import com.lh.api.form.RegisterForm;
import com.lh.common.utils.PageUtils;
import com.lh.common.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * APP测试接口
 *
 * @author Mark sunlightcs@gmail.com
 */
@RestController
@RequestMapping("/app")
@Api("APP测试接口")
public class AppTestController {

    @Login
    @GetMapping("userInfo")
    @ApiOperation("获取用户信息")
    public Result<String> userInfo(@LoginUser UserEntity user){
        return Result.ok(user);
    }

    @Login
    @GetMapping("userId")
    @ApiOperation("获取用户ID")
    public Result<String> userInfo(@RequestAttribute("userId") Integer userId){
        return Result.ok(userId);
    }

    @GetMapping("notToken")
    @ApiOperation("忽略Token验证测试")
    public Result<String> notToken(){
        return Result.ok("无需token也能访问。。。");
    }


    @PostMapping("test")
    @ApiOperation("测试")
    public Result<PageUtils<UserEntity>> test(@RequestBody RegisterForm form){
        return null;
    }

}
